package com.hospital.wx.service.Impl;

import com.hospital.wx.dao.DoctorsDao;
import com.hospital.wx.pojo.Doctors;
import com.hospital.wx.service.DoctorsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

@Service
@Slf4j
public class DoctorsServiceImpl implements DoctorsService {

    @Autowired
    private DoctorsDao doctorsDao;

    @Override
    public HashMap<String, Doctors> selectTelByNameOrDeptName(String param) {
        List<Doctors> doctorsList;
        HashMap<String, Doctors> doctorsMap = new HashMap<>();
        if (param != "" && param != null) {
            doctorsList = doctorsDao.selectTelByNameOrDeptName(param);
        }else{
            doctorsList = doctorsDao.selectByConsultCount();
        }
        for (Doctors doctor : doctorsList) {
            // 使用唯一的 id 作为键
            doctorsMap.put(String.valueOf(doctor.getId()), doctor);
        }
        return doctorsMap;
    }

    @Override
    public List<HashMap> selectAll() {
        return doctorsDao.selectAll();
    }

    @Override
    public HashMap selectDoctorInfoById(int id) {
        return doctorsDao.selectDoctorInfoById(id);
    }

}
